import request from '@/utils/request'
import { getToken } from '@/utils/auth'

const pref = '/sysUser'

export const getPage = (param) => {
  return request.post(pref + '/getPage', param)
}

export const getList = (param) => {
  return request.post(pref + '/getList', param)
}

export const deleteById = (id) => {
  return request.delete(pref + '?id=' + id)
}

export const save = (param) => {
  return request.post(pref, param)
}

export const register = (param) => {
  return request.post(pref + '/register', param)
}

export const getOne = (id) => {
  return request.get(pref + '?id=' + id)
}

export const login = (data) => {
  return request.post(pref + '/login', data)
}

export const getInfo = (token) => {
  return request.get(pref + '/info', token)
}

export const getInfos = () => {
  return request.get(pref + '/info', getToken())
}

export const getUserRole = (id) => {
  return request.post('/sysUser/getUserRole?id=' + id)
}

export const dispense = (param) => {
  return request.post('/sysUser/dispense', param)
}

export const logout = () => {
  return request.post('/sysUser/logout')
}
